//
//  YHViewController.m
//  YHRouter
//
//  Created by 林宁宁 on 11/26/2021.
//  Copyright (c) 2021 林宁宁. All rights reserved.
//

#import "YHViewController.h"
@import YHRouter;

@interface YHViewController ()

@end

@implementation YHViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    self.title = @"Router";
    
    [UIView appearance].backgroundColor = [UIColor whiteColor];
    
    YHOptionTableViewItem * item;
    
    item = YHOptionTableItemInitTitleContent(@"Module1", @"push/present actions");
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"YHModuleOneViewController_1"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitleContent(@"Module2", @"params/callback/protocol");
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"YHModuleTwoViewController_1"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitleContent(@"Module3", @"vc handle actions");
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"YHModuleThreeViewController_1"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitleContent(@"Module4", @"model mediator actions");
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"YHModuleFourViewController_1"];
    }];
    [self addOptionItem:item];
    
    [self reloadContentView];
    
    
    [[YHRouter sharedManager] setErrorHandler:^(YHRouterErrorCode code, NSString * _Nonnull exceptionDescription) {
       
        NSLog(@"出现错误 === %@", exceptionDescription);
    }];
    [YHRouter sharedManager].urlScheme = @"router";
    [YHRouter sharedManager].URLPageKeypaths = @[@"id",@"page"];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
